package com.csesteel.crm.control;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/crm")
public class CRMController extends BaseController{

    @RequestMapping(value = "/loginSuccess", method = RequestMethod.POST)
    public ModelAndView loginIn(ModelMap modelMap) {
        ModelAndView modelAndView = new ModelAndView();
        //TODO
        if (true) {
            modelAndView.setViewName("manage");
            return modelAndView;
        } else {
            return modelAndView;
        }
    }

    //客户管理
    @RequestMapping(value = "/getLoginPage", method = RequestMethod.GET)
    public String getLoginPage() {
        return "login";
    }

    @RequestMapping(value = "/getMyselfClientInfo", method = RequestMethod.GET)
    public String getMyselfClientInfo() {
        return "customer/myself_client_info";
    }

    @RequestMapping(value = "/getConnectRecordPage", method = RequestMethod.GET)
    public String getConnectRecordPage() {
        return "customer/connect_record";
    }

    @RequestMapping(value = "/getFollowUpPlanPage", method = RequestMethod.GET)
    public String getFollowUpPlanPage() {
        return "customer/follow_up_plan";
    }

    @RequestMapping(value = "/getGonghaiCustomerInfoPage", method = RequestMethod.GET)
    public String getGonghaiCustomerInfoPage() {
        return "customer/gonghai_customer_info";
    }

    @RequestMapping(value = "/getViewRecords/{customerId}/{tabId}", method = RequestMethod.GET)
    public String getViewRecords(@PathVariable("customerId") String customerId,
                                 @PathVariable("tabId") String tabId,
                                ModelMap modelMap) {
        String customerInfo = "{\"totalNumber\":3,\"list\":[{\"customerId\":\"22\", \"customerName\":\"张三\", \"customerGrade\":\"潜在客户\",\"idNumber\":\"333333333333333333\",\"recordTime\":\"2015-6-9\",\"contact\":\"李四\", \"responsiblePerson\":\"责任人\",\"customerType\":\"生产企业\",\"source\":\"网站注册\",\"phoneNumber\":\"111111111\", \"industry\":\"钢铁\"}]}";
        modelMap.addAttribute("tabId",tabId);
        modelMap.addAttribute("customerInfo", customerInfo);
        modelMap.addAttribute("trackRecords","{\"totalNumber\":3,\"list\":[{\"recordId\":11,\"recordMan\":\"zhangsan\",\"recordTime\":\"20150505\",\"recordType\":\"A\",\"recordContent\":\"kk ask food\",\"nextCallTime\":\"20150605\",\"callbackType\":\"I\"}]}");
        return "customer/view_records";
    }

    @RequestMapping(value = "/editCustomerInfo/{customerId}", method = RequestMethod.GET)
    public String editCustomerInfo(@PathVariable("customerId") String customerId, ModelMap modelMap) {
        String customerInfo = "{\"totalNumber\":3,\"list\":[{\"customerId\":\"22\", \"customerName\":\"张三\", \"customerGrade\":\"潜在客户\",\"idNumber\":\"333333333333333333\",\"recordTime\":\"2015-6-9\",\"contact\":\"李四\", \"responsiblePerson\":\"责任人\",\"customerType\":\"生产企业\",\"source\":\"网站注册\",\"phoneNumber\":\"111111111\", \"industry\":\"钢铁\"}]}";
        modelMap.addAttribute("customerInfo", customerInfo);
        return "customer/edit_customer";
    }


    //    三级菜单
    @RequestMapping(value = "/addCustomerInfo", method = RequestMethod.GET)
    public String getAddOrEditCustomerPage() {
        return "customer/add_customer";
    }

    @RequestMapping(value = "/getCustomerDistribution", method = RequestMethod.GET)
    public String getCustomerDistribution() {
        return "customer/customer_distribution";
    }

    @RequestMapping(value = "/getCustomerImport", method = RequestMethod.GET)
    public String getCustomerImport() {
        return "customer/customer_import";
    }

    @RequestMapping(value = "/getSendMessage", method = RequestMethod.GET)
    public String getSendMessage() {
        return "customer/send_message";
    }

    @RequestMapping(value = "/getCheckMessage", method = RequestMethod.GET)
    public String getCheckMessage() {
        return "customer/check_message";
    }

//    权限管理
    @RequestMapping(value = "/userManage", method = RequestMethod.GET)
    public String userManage() {
        return "permission/user_management";
    }

    @RequestMapping(value = "/roleManage", method = RequestMethod.GET)
    public String roleManagement() {
        return "permission/role_management";
    }

    @RequestMapping(value = "/permissionManage", method = RequestMethod.GET)
    public String permissionManage() {
        return "permission/permission_management";
    }


//  系统管理
    @RequestMapping(value = "/dataManage", method = RequestMethod.GET)
    public String dataManage() {
        return "system/data_management";
    }

    @RequestMapping(value = "/dictionaryManage", method = RequestMethod.GET)
    public String dictionaryManage() {
        return "system/dictionary_management";
    }

    @RequestMapping(value = "/dictionaryMaintain/{dictionaryId}", method = RequestMethod.GET)
    public String dictionaryMaintain(@PathVariable("dictionaryId") String dictionaryId,
                                     ModelMap modelMap) {
        String dictionaryDetail = "{\"totalNumber\":5,\"list\":[{\"detail\":\"农业\"},{\"detail\":\"林业\"},{\"detail\":\"牧业\"},{\"detail\":\"副业\"},{\"detail\":\"渔业\"}]}";
        modelMap.addAttribute("dictionaryDetail", dictionaryDetail);
        modelMap.addAttribute("dictionaryColumnName", "行业类型");
        return "system/dictionary_maintain";
    }

    @RequestMapping(value = "/parameterManage", method = RequestMethod.GET)
    public String parameterManage() {
        return "system/parameter_management";
    }

    @RequestMapping(value = "/passwordModification", method = RequestMethod.GET)
    public String passwordModification() {
        return "system/password_modification";
    }


}
